package cn.bincker.mybatis.encrypt.converter.impl;

import java.nio.ByteBuffer;
import java.util.Date;

public class DateEncryptConverter extends BaseEncryptConverter<Date>{
    @Override
    public Date convertNonNull(byte[] data) {
        return new Date(ByteBuffer.wrap(data).getLong());
    }

    @Override
    public byte[] convertNonNull(Date object) {
        var result = new byte[Long.BYTES];
        ByteBuffer.wrap(result).putLong(object.getTime());
        return result;
    }
}
